package com.kt.controller;

import com.kt.domain.Order;
import com.kt.service.imp.OrderServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/pay.do")
public class PayServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        OrderServiceImp orderServiceImp = new OrderServiceImp();
        Order order = orderServiceImp.findById(req.getParameter("oid"));
        order.setState(1);
        int result = orderServiceImp.changeOrderInfo(order);
        if (result == 0) {
            resp.getWriter().write("error");
            return;
        }
        resp.getWriter().write("ok");
    }
}
